/* AclEntity - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
package net.da.core.entity;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * This entity may need field "language" also.
 * @author dzifuta
 *
 */

@NamedQueries({
    @NamedQuery (name="ApplicationSession.findTimedOutApplicationSessions",
            query="SELECT applicationSession " +
                "FROM ApplicationSessionEntity applicationSession " +
                "WHERE applicationSession.expirationTime < :currentTime")
    })

@Entity
@Table(name="sessions")
public class ApplicationSessionEntity extends PersistentObjectEntity {

    @Column(nullable = false)
    private String sessionId;

    @Temporal(TemporalType.DATE)
    private Calendar lastTime;

    @Temporal(TemporalType.DATE)
    private Calendar expirationTime;

//  =============================================================
    @OneToOne
    @JoinColumn(name = "sys_user_id")
    private SysUserEntity sysUser;

    @OneToOne
    @JoinColumn(name = "organisation_user_id")
    private OrganisationUserEntity organisationUser;
//  =============================================================

    public Calendar getExpirationTime() {
        return expirationTime;
    }

    public void setExpirationTime(Calendar expirationTime) {
        this.expirationTime = expirationTime;
    }

    public Calendar getLastTime() {
        return lastTime;
    }

    public void setLastTime(Calendar lastTime) {
        this.lastTime = lastTime;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public OrganisationUserEntity getOrganisationUser() {
        return organisationUser;
    }

    public void setOrganisationUser(OrganisationUserEntity organisationUser) {
        this.organisationUser = organisationUser;
    }

    public SysUserEntity getSysUser() {
        return sysUser;
    }

    public void setSysUser(SysUserEntity sysUser) {
        this.sysUser = sysUser;
    }

}
